package com.polaris.live.adapter.chatPrice

import com.blankj.utilcode.util.ColorUtils
import com.blankj.utilcode.util.StringUtils
import com.polaris.live.common.R.color
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.common.ext.toLevel
import com.polaris.live.databinding.AdapterSetPriceBinding
import com.polaris.live.resp.back_resp.UserCallPriceBaseVo
import com.polaris.live.translation.R.string

/**
 * 设置价格列表
 *
 * @author Created by 长空 on 2023/11/08/004 14:06
 */
class SetPriceAdapter :
    BaseBindingAdapter<AdapterSetPriceBinding, UserCallPriceBaseVo>() {

    private var mPrice = 0L

    override fun convert(holder: VBViewHolder<AdapterSetPriceBinding>, item: UserCallPriceBaseVo) {
        holder.vb.apply {
            tvDiamond.text = item.price.toString()
            tvMin.text = "/${StringUtils.getString(string.min)}(${
                StringUtils.getString(string.level_anchor, item.minLevel.toLevel)
            })"

            if (item.setting) {
                holder.itemView.isEnabled = true
                tvDiamond.alpha = 1f
                ivDiamond.alpha = 1f
                tvMin.alpha = 1f
            } else {
                holder.itemView.isEnabled = false
                tvDiamond.alpha = 0.3f
                ivDiamond.alpha = 0.3f
                tvMin.alpha = 0.3f
            }

            if (mPrice == item.price) {
                tvDiamond.setTextColor(ColorUtils.getColor(color.color_fe1849))
                tvMin.setTextColor(ColorUtils.getColor(color.color_fe1849))
            } else {
                tvDiamond.setTextColor(ColorUtils.getColor(color.color_202028))
                tvMin.setTextColor(ColorUtils.getColor(color.color_202028))
            }
        }
    }

    fun setUserPrice(price: Long) {
        mPrice = price
        notifyDataSetChanged()
    }

}